package collections;

import java.util.ArrayList;
import java.util.Iterator;




class TestArrayList {
	public static void main(String args[]) {
	// create an array list
	ArrayList<String> al = new ArrayList<String>(12);
	

	System.out.println("Initial size of al: " +al.size());
	// add elements to the array list
	al.add("Cat");
	al.add("A");
	al.add("E");
	al.add("B");
	al.add("D");
	al.add("F");
	al.add(1, "A2");
	System.out.println("Size of al after additions: " +al.size());
	// display the array list
	System.out.println("Contents of al: " + al);
	Iterator<String> it=al.iterator();
	while(it.hasNext()){
		System.out.println(" "+it.next());
		
	}
	for(String k:al)
		System.out.println(""+k);
	// Remove elements from the array list
	
	al.remove("F");
	al.remove(2);
	System.out.println("Size of al after deletions: " +
	al.size());
	System.out.println("Contents of al: " + al);
	al.ensureCapacity(35);                            //Imp..
	System.out.println("New size :"+al.size());
	}
	}